<template>
     <el-dialog v-model="dialogShow" title="新增合作伙伴" width="760px" close-on-click-modal="false" :before-close="clickOff">
      <el-form :model="form" ref="submitForm" label-width="auto" :rules="rules">

           <el-form-item label="图片：" prop="logo">
               <el-upload :headers="{ token: token }" :action=uploadUrl :on-success="(val) => uploadSuccess(val, 1, 'logo')"
                   class="avatar-uploader" accept="image/*" :show-file-list="false" name="files">
                   <img v-if="form.logo" :src="form.logo" class="dialog1_img1" />
                   <el-icon v-else class="avatar-uploader-icon">
                       <Plus />
                   </el-icon>
               </el-upload>
               <div class="dialog1_prompt1">请添加活动封面，建议尺寸比例16:9，大小不超过2M</div>
           </el-form-item>

        </el-form>
        <template #footer>
                    <span class="dialog-footer">
                        <el-button @click="clickOff(); ; form = [{}]">取消</el-button>
                        <el-button type="primary" @click="submit()">确定</el-button>
                    </span>
        </template>
        </el-dialog>



</template>
<script>
    
export default {
    data() {
        return {
            dialogShow: true,
            id: '',
            loading: false,
            form: {}, content: '',
            classificationL: [],
            param: {},
            uploadUrl: `/api/system/upload/uploadList`,
        }
    },

    created() {
    },

    mounted() {
    },

    components: {
    },

    methods: {
        uploadSuccess(val, num, key) {
            console.log('111111', val, key)
            if (num == 1) {//单张
                console.log('this.utils.Decrypt(val.data).path', this.utils.Decrypt(val.data))
                this.form[key] = this.utils.Decrypt(val.data).path
            } else {//多张
                console.log(11111)
                if (this.form[key]) { } else { this.form[key] = [] }
                this.form[key].push({ url: this.utils.Decrypt(val.data).path, src: this.utils.Decrypt(val.data).path })
            }
            this.loading = false;
        },



        clickOff(){
           this.$parent.dialogShow349 = false;
           this.dialogShow = false;
        },



        submit() {
            console.log(this.form, 'this.form=============')
            let that = this;
            that.$parent.dialogShow = false
            that.$refs['submitForm'].validate((val) => {
                if (val) {
                    let form = JSON.parse(JSON.stringify(that.form))
                        that.$api.insert(form).then(res => {
                    that.fullscreenLoading = false;
                    console.log(res);
                    if (res) {
                        that.$message.success(res.message);
                        this.$parent.dialogShow1 = false;
                        this.dialogShow = true;
                    }
                    });
                }
            })
        },



    }

}


</script>
<style lang="scss" scoped>

.div1{
    background-color: #fff;
    padding: 25px;
    box-sizing: border-box;
}
.buttons1{
    width: 100%;
    display: flex;
    justify-content: center;
    .buttons1_button1{
        width: 200px;
        height: 50px;
    }
}
.dialog1_title1 {
    display: inline-block;
    font-size: 12px;
    color: #9e9e9e;
    width: 100%;
}

.dialog1_prompt1 {
    display: inline-block;
    color: #9e9e9e;
    line-height: 20px;
    padding-top: 10px;
    font-size: 12px;
    text-align: left;
    width: 100%;
}

.dialog1_prompt2 {
    display: inline-block;
    color: #9e9e9e;
    line-height: 20px;
    padding-top: 10px;
    font-size: 12px;
    text-align: left;
    width: 100%;
}

.dialog1_video1 {
    width: 500px;
}

.dialog1_img1 {
    width: 300px;
}

.dialog1_img2 {
    width: 100px;
    height: 100px;
    margin-right: 20px;
}

</style>